
/****** Object:  StoredProcedure [usp_GetDealersMasterByID]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_GetDealersMasterByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_GetDealersMasterByID];
GO

CREATE PROCEDURE [usp_GetDealersMasterByID]
(
	@DealerID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[DealerID],
		[DealerName],
		[Counter],
		[Address],
		[ContactNo],
		[LastModifiedUser],
		[LastModifiedDateTime]
	FROM [DealersMaster]
	WHERE
		([DealerID] = @DealerID)

	SET @Err = @@Error

	RETURN @Err
END
GO


/****** Object:  StoredProcedure [usp_GetAllDealersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_GetAllDealersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_GetAllDealersMaster];
GO

CREATE PROCEDURE [usp_GetAllDealersMaster]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[DealerID],
		[DealerName],
		[Counter],
		[Address],
		[ContactNo],
		[LastModifiedUser],
		[LastModifiedDateTime]
	FROM [DealersMaster]

	SET @Err = @@Error

	RETURN @Err
END
GO


/****** Object:  StoredProcedure [usp_UpdateDealersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_UpdateDealersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_UpdateDealersMaster];
GO

CREATE PROCEDURE [usp_UpdateDealersMaster]
(
	@DealerID int,
	@DealerName varchar(50),
	@Counter varchar(50),
	@Address varchar(MAX),
	@ContactNo varchar(20) = NULL,
	@LastModifiedUser int,
	@LastModifiedDateTime datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [DealersMaster]
	SET
		[DealerName] = @DealerName,
		[Counter] = @Counter,
		[Address] = @Address,
		[ContactNo] = @ContactNo,
		[LastModifiedUser] = @LastModifiedUser,
		[LastModifiedDateTime] = @LastModifiedDateTime
	WHERE
		[DealerID] = @DealerID


	SET @Err = @@Error


	RETURN @Err
END
GO




/****** Object:  StoredProcedure [usp_InsertDealersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_InsertDealersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_InsertDealersMaster];
GO

CREATE PROCEDURE [usp_InsertDealersMaster]
(
	@DealerID int = NULL output,
	@DealerName varchar(50),
	@Counter varchar(50),
	@Address varchar(MAX),
	@ContactNo varchar(20) = NULL,
	@LastModifiedUser int,
	@LastModifiedDateTime datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [DealersMaster]
	(
		[DealerName],
		[Counter],
		[Address],
		[ContactNo],
		[LastModifiedUser],
		[LastModifiedDateTime]
	)
	VALUES
	(
		@DealerName,
		@Counter,
		@Address,
		@ContactNo,
		@LastModifiedUser,
		@LastModifiedDateTime
	)

	SET @Err = @@Error

	SELECT @DealerID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


/****** Object:  StoredProcedure [usp_DeleteDealersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_DeleteDealersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_DeleteDealersMaster];
GO

CREATE PROCEDURE [usp_DeleteDealersMaster]
(
	@DealerID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [DealersMaster]
	WHERE
		[DealerID] = @DealerID
	SET @Err = @@Error

	RETURN @Err
END
GO

